const App = getApp();

Page({
    data: {
        isLoading: false,
        reLoading: false,
        number: '',
    },
    onLoad: function (options) {

    },

    inputNum(e) {
        this.setData({
            number: e.detail.value
        })
    },

    // 提交表单
    submit() {
        let _this = this;
        if (!_this.data.number.length) {
            wx.showToast({
                title: '请输入激活卡密',
                icon: 'none',
            })
            return false;
        }

        wx.showModal({
            title: '温馨提示',
            content: '确定要激活此卡密吗?',
            success(res) {
                if (res.confirm) {
                    _this.setData({
                        reLoading: true
                    });
                    App._post_form('card/activation', {
                        number: _this.data.number
                    }, res => {
                        wx.showToast({
                            title: res.msg,
                            icon: 'success',
                            duration: 2000,
                            success: function () {
                                wx.switchTab({
                                    url: '/pages/member/member'
                                })
                            }
                        })
                    }, false, () => {
                        _this.setData({
                            reLoading: false
                        });
                    });
                }
            }
        })

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function (res) {
        return {
            title: '代理卡密激活',
        }
    },

    onShareTimeline: function (res) {
        return {
            title: '代理卡密激活',
        }
    },

});
